﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using OVS_TrajectoryCalculation.Manager;
using OVS_FormsRecognition.Manager;
using OVS_Tools;

namespace OVS_TrajectoryCalculation
{
    /// <summary>
    /// Logique d'interaction pour TrajectoryCalculationMain.xaml
    /// </summary>
    public partial class TrajectoryCalculationMain : Window
    {
        /// <summary>
        /// Logger par défaut du ManagerUtilisateurs
        /// </summary>
        private static readonly log4net.ILog _Log = log4net.LogManager.GetLogger(typeof(TrajectoryCalculationManager));


        public TrajectoryCalculationMain()
        {
            InitializeComponent();

            FormsRecognitionManager.Instance.TrajectoryCalculationEventNewCapture += new FormsRecognitionManager.TrajectoryCalculationEventHandler(CallBackTrajectoryCalculationEventNewCapture);
            FormsRecognitionManager.Instance.TrajectoryCalculationEventStopCapture += new FormsRecognitionManager.TrajectoryCalculationEventHandler(CallBackTrajectoryCalculationEventStopCapture);
        }

        /// <summary>
        /// Calls the back size calculation start event.
        /// </summary>
        /// <param name="nullObject">The null object.</param>
        /// <param name="pSizeCalculationEventArgs">The <see cref="SizeCalculationEventArgs" /> instance containing the event data.</param>
        private void CallBackTrajectoryCalculationEventNewCapture(object nullObject, TrajectoryCalculationEventArgs pSizeCalculationEventArgs)
        {
            _Log.Debug("new event CallBackTrajectoryCalculationEventNewCapture !!!");

            UIThreadHelper.UIThread(this, delegate
            {
                _Log.Debug("new event CallBackTrajectoryCalculationEventNewCapture !!!");

                if (labelLastAlertInfo != null)
                {
                    String strDate = String.Format("{0:d-M-yyyy HH:mm:ss}", DateTime.Now);
                    labelLastAlertInfo.Content = String.Format("New Alert: camId:  date: {0}", strDate);
                }
            });
        }
        /// <summary>
        /// Calls the back size calculation start event.
        /// </summary>
        /// <param name="nullObject">The null object.</param>
        /// <param name="pSizeCalculationEventArgs">The <see cref="SizeCalculationEventArgs" /> instance containing the event data.</param>
        private void CallBackTrajectoryCalculationEventStopCapture(object nullObject, TrajectoryCalculationEventArgs pSizeCalculationEventArgs)
        {
            _Log.Debug("new event CallBackTrajectoryCalculationEventStopCapture !!!");

            UIThreadHelper.UIThread(this, delegate
            {
                _Log.Debug("new event CallBackTrajectoryCalculationEventNewCapture !!!");

                if (labelLastAlertInfo != null)
                {
                    String strDate = String.Format("{0:d-M-yyyy HH:mm:ss}", DateTime.Now);
                    labelLastAlertInfo.Content = String.Format("Stop: camId:  date: {0}", strDate);
                }
            });

        }
    }
}
